#include "Menu.h"
Menu::Menu()
{
	m_pFont = NULL;
	m_subFont = NULL;
	m_pTexture = NULL;
	m_pGridTexture = NULL;
	m_pSprite = NULL;
	m_button = NULL;
	//m_menuState = MAIN_MENU;
	m_BBx = 0.0f;
	m_BBy = 0.0f;
	//BUTTON_MENU_POS_X		=		0.5f;
	//BUTTON_MENU_POS_Y		=		0.35f;
	m_mouseDown = false;
	m_windowed = true;
	//m_musicMute = false;
	//m_soundMute = false;
	//m_SoundVolume = INIT_VOLUME;
	//m_MusicVolume = INIT_VOLUME;
	m_pressedPlay = false;

	m_clicked = false;
	m_galaxy = true;

	for(int i = 0; i < MAX_SECTORS; ++i)
	{
		m_sectorPos[i] = D3DXVECTOR2(0.0f,0.0f);
		m_QuadPos[i] = D3DXVECTOR2(0.0f,0.0f);
	}
	m_sectorSelected = 0;
	m_QuadSelected = 0;

	//m_msgIn.SetShip(0,0,0);
	m_msgIn.SetSystems(true,true,true,true,true,true);
	//m_msgIn.SetSystems(false,false,false,false,false,false);
}
Menu::~Menu()
{
	MenuClear();
	m_pFont->Release();
	//	m_subFont->Release();
	m_pTexture->Release();
	m_pSprite->Release();
}

void Menu::MenuInit(HWND hW, float BBx, float BBy)
{
	hWnd = hW;//set the handle to the window
	m_BBx = BBx;
	m_BBy = BBy;

	D3DXCreateFont(m_pD3DDevice, 20, 0, FW_BOLD, 0, false, DEFAULT_CHARSET, 
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Times New Roman", &m_pFont);

	//D3DXCreateFont(m_pD3DDevice, 26, 0, FW_BOLD, 0, false, DEFAULT_CHARSET, 
	//	OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Times New Roman", &m_subFont);

	D3DXCreateSprite(m_pD3DDevice, &m_pSprite);

	D3DXCreateTextureFromFileEx(m_pD3DDevice, L"MenuBackground.png",BACKGROUND_W, BACKGROUND_H, 1, 0, 
		D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 
		D3DCOLOR_XRGB(255, 255, 255), 0, NULL, &m_pTexture);

	//D3DXCreateTextureFromFileEx(m_pD3DDevice, L"empty.png",D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1, 0, 
	//	D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 
	//	D3DCOLOR_XRGB(255, 255, 255), 0, NULL, &m_pGridTexture);


	//int a(0),x(50),y(40);
	//for(int i = 0; i < MAX_COLS; ++i) //Eight columns
	//{
	//	for(int j = 0; j < MAX_ROWS; ++j) //by eight rows
	//	{
	//		m_sectorPos[a].x = x;
	//		m_sectorPos[a].y = y;
	//		x += 62;
	//		a++;

	//	}
	//	x = 50;
	//	y += 62;
	//}

	LoadMap();
	LoadGButtons();
	LoadQButtons();
}
void Menu::LoadMap(void)
{
	//loop through the number of buttons, initialize and add to the vector
	int a(0);
	float x(.10f),y(.07f);
	//int a(0),x(50),y(40);
	for(int i = 0; i < MAX_COLS; ++i) //Eight columns
	{
		for(int j = 0; j < MAX_ROWS; ++j) //by eight rows
		{
			//load quadrant sprite
			m_button= new MenuButton(a, 
				x, y, m_BBx,m_BBy, 64, 64,						//texture size
				L"empty_un.png", m_pSprite, hWnd);
			vQuads.push_back(m_button);	//adds button to the end of the list
			
			//load sector sprites
			m_button= new MenuButton(a, 
				x, y, m_BBx,m_BBy, 64, 64,						//texture size
				L"empty.png", m_pSprite, hWnd);
			vSects.push_back(m_button);	//adds button to the end of the list

			x += .113f;//incrementX
			a++;
		}
		x = .10f;//reset X
		y += .058f;//increment Y
	}

}
void Menu::DrawMap(void)
{
	m_pSprite->Begin(D3DXSPRITE_ALPHABLEND |D3DXSPRITE_SORT_DEPTH_FRONTTOBACK );//|D3DXSPRITE_OBJECTSPACE);    // begin sprite drawing with transparency

	RECT r;
	GetWindowRect(hWnd, &r);
	r.right = r.right - r.left;
	r.bottom = r.bottom - r.top;
	r.left = 0;
	r.top = 0;

	//draws separator between map and ui elements
	m_pSprite->Draw(m_pTexture, 0, 
		&D3DXVECTOR3(0.0f, 0.0f, 0.0f), 
		&D3DXVECTOR3(0.0f, 0.0f, 0.0f),
		D3DCOLOR_ARGB(255,255,255,255));
	if(m_galaxy)
	{
		m_pFont->DrawText(0, L"GALAXY",	
			-1, &r, DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		Vec_Quadrants::iterator i = vQuads.begin();

		//loop and render all
		while (i != vQuads.end())
		{
			(*i)->Render(true);
			i++;
		}
		DrawGButtons();
	}
	else
	{
		m_pFont->DrawText(0, L"QUADRANT",	
			-1, &r, DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		Vec_Sectors::iterator o = vSects.begin();

		//loop and render all
		while (o != vSects.end())
		{
			(*o)->Render(true);
			o++;
		}
		DrawQButtons();
	}
	m_pSprite->End();
}
void Menu::LoadGButtons(void)
{
	m_button= new MenuButton(SHIELD_PLUS, 
		1.500f, 0.38f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"+", m_pSprite, m_pFont, hWnd);
	vGButtons.push_back(m_button);
	m_button= new MenuButton(SHIELD_MINUS, 
		1.700f, 0.38f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"-", m_pSprite, m_pFont, hWnd);
	vGButtons.push_back(m_button);
	m_button= new MenuButton(SWITCH_MAP, 
		1.200f, 0.5f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"Enter", m_pSprite, m_pFont, hWnd);
	vGButtons.push_back(m_button);
	m_button= new MenuButton(SCAN, 
		1.5f, 0.45f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"Scan", m_pSprite, m_pFont, hWnd);
	vGButtons.push_back(m_button);
	m_button= new MenuButton(QUIT, 
		1.8f, 0.5f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"X", m_pSprite, m_pFont, hWnd);
	vGButtons.push_back(m_button);


}
void Menu::DrawGButtons(void)
{
	Vec_GButtons::iterator b = vGButtons.begin();
	while (b != vGButtons.end())
	{
		(*b)->Render(false);
		b++;
	}

}
void Menu::LoadQButtons(void)
{
	//MAGICNUMBERS!!!!
	m_button= new MenuButton(SHIELD_PLUS, 
		1.500f, 0.38f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"+", m_pSprite, m_pFont, hWnd);
	vQButtons.push_back(m_button);
	m_button= new MenuButton(SHIELD_MINUS, 
		1.700f, 0.38f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"-", m_pSprite, m_pFont, hWnd);
	vQButtons.push_back(m_button);

	m_button= new MenuButton(SWITCH_MAP, 
		1.200f, 0.5f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"Galaxy", m_pSprite, m_pFont, hWnd);
	vQButtons.push_back(m_button);
	m_button= new MenuButton(QUIT, 
		1.8f, 0.5f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"X", m_pSprite, m_pFont, hWnd);
	vQButtons.push_back(m_button);
	m_button= new MenuButton(BLASTER, 
		1.5f, 0.45f, m_BBx,m_BBy,
		32, 64,
		L"button.png", 
		L"FIRE!", m_pSprite, m_pFont, hWnd);
	vQButtons.push_back(m_button);


}
void Menu::DrawQButtons(void)
{
	Vec_QButtons::iterator q = vQButtons.begin();
	while (q != vQButtons.end())
	{
		(*q)->Render(false);
		q++;
	}

}
void Menu::MenuInput(void)
{
	if(gDInput->mouseButtonDown(0))
	{
		m_clicked = true;
	}
	//static int a = 0;
	if(m_galaxy)
	{
		Vec_Quadrants::iterator i = vQuads.begin();
		while (i != vQuads.end())
		{				
					m_QuadSelected = (*i)->GetID();
					m_QuadPos[m_QuadSelected] = D3DXVECTOR2((*i)->GetX(),(*i)->GetY());

			//update buttons- check if mouse is hovered over buttons
			if((*i)->isMouseOver())//&& (*i)->GetID() == BUTTON_PLAY)
			{
				//checks if Left mouse button(0) was clicked
				if(gDInput->mouseButtonDown(0))
				{
					//reset all pressed tiles.. Not the best way?
					for(int u = 0; u < (int)vQuads.size(); ++u)
					{
						vQuads.at(u)->Unpressed();
					}
					(*i)->Pressed();		m_clicked = true;
					m_msgOut.SetInfo(0,'G',m_QuadSelected);
				}
			}
			++i;
		}
	}
	else
	{
		Vec_Sectors::iterator o = vSects.begin();
		while (o != vSects.end())
		{					
			m_sectorSelected = (*o)->GetID();
					m_sectorPos[m_sectorSelected] = D3DXVECTOR2((*o)->GetX(),(*o)->GetY());

			if((*o)->isMouseOver())//&& (*i)->GetID() == BUTTON_PLAY)
			{
				if(gDInput->mouseButtonDown(0))
				{
					for(int u = 0; u < (int)vSects.size(); ++u)
					{
						vSects.at(u)->Unpressed();//reset all pressed tiles
					}

					(*o)->Pressed();		m_clicked = true;
					//m_pressedPlay = true;
					m_msgOut.SetInfo(0,'Q',m_sectorSelected);

				}
			}
			++o;
		}
	}
	Vec_GButtons::iterator g = vGButtons.begin();
	while (g != vGButtons.end())
	{
		if(gDInput->mouseButtonDown(0) && (*g)->isMouseOver())
		{
			if( !m_mouseDown )
			{
				m_mouseDown = true;
			}
		}
		++g;
	}
	Vec_QButtons::iterator q = vQButtons.begin();
	while (q != vQButtons.end())
	{
		if(gDInput->mouseButtonDown(0) && (*q)->isMouseOver())
		{
			if( !m_mouseDown )
			{
				m_mouseDown = true;
			}
		}
		++q;
	}	
	CheckButtons();
}
void Menu::CheckButtons(void)
{
	Vec_GButtons::iterator g = vGButtons.begin();
	if(m_galaxy)
	{
		while (g != vGButtons.end())
		{
			//update buttons- check if mouse is hovered over buttons
			if((*g)->isMouseOver()&& (*g)->GetID() == SHIELD_PLUS)
			{
				if(m_mouseDown)
				{
					(*g)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{
						m_msgOut.SetInfo(0,'+',100);
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}

			}
			if((*g)->isMouseOver()&& (*g)->GetID() == SHIELD_MINUS)
			{
				if(m_mouseDown)
				{
					(*g)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{
						m_msgOut.SetInfo(0,'-',-100);
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}

			}
			if((*g)->isMouseOver()&& (*g)->GetID() == SWITCH_MAP)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*g)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{				
						m_galaxy = false;
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}

			}

			if((*g)->isMouseOver()&& (*g)->GetID() == SCAN)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*g)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{
						m_msgOut.SetInfo(0,'S',0);
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}

			}

			if((*g)->isMouseOver()&& (*g)->GetID() == QUIT)
			{
				if(m_mouseDown)
				{
					(*g)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}

			}
			++g;
		}
	}
	else
	{
		Vec_QButtons::iterator q = vQButtons.begin();

		while (q != vQButtons.end())
		{
			//update buttons- check if mouse is hovered over buttons
			if((*q)->isMouseOver()&& (*q)->GetID() == SHIELD_PLUS)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*q)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{		
						m_msgOut.SetInfo(0,'+',100);
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}
			}
			if((*q)->isMouseOver()&& (*q)->GetID() == SHIELD_MINUS)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*q)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{		
						m_msgOut.SetInfo(0,'-',-100);
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}
			}
			if((*q)->isMouseOver()&& (*q)->GetID() == BLASTER)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*q)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{		
						m_msgOut.SetInfo(0,'B',10000);
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}
			}
			if((*q)->isMouseOver()&& (*q)->GetID() == SWITCH_MAP)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*q)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{		
						m_galaxy = true;
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}
			}
			if((*q)->isMouseOver()&& (*q)->GetID() == QUIT)
			{
				//checks if Left mouse button(0) was clicked
				if(m_mouseDown)
				{
					(*q)->Pressed();
					if(!gDInput->mouseButtonDown(0))
					{		
						m_mouseDown = false;	(*g)->Unpressed();
					}
				}
				else
				{	if(m_mouseDown)	{m_mouseDown = false;	(*g)->Unpressed();}	}
			}
			++q;
		}
	}

}

void Menu::Update(float dt,float BBx, float BBy)
{
	// Calculate RECT structure for text drawing placement, using whole screen
	GetWindowRect(hWnd, &rect);
	rect.right = rect.right - rect.left;
	rect.bottom = rect.bottom - rect.top;
	rect.left = 0;
	rect.top = 0;
}
void Menu::Render()
{
	DrawMap();
	MenuText();

}
void Menu::MenuText(void)
{
	m_msgOut.ConvertCoords(m_sectorSelected);

	GetWindowRect(hWnd, &rect);
	rect.right = 1100;
	rect.bottom = 600;
	rect.left = 600;
	rect.top = 0;

	//text buffer to store the text to print
	wchar_t textbuff[256];

	if(m_galaxy)
	{
		//prints location info
		swprintf_s(textbuff, _countof(textbuff), 
			L"QUADRANT INFO: %d, %d\nSTARS: %d\nSTATIONS: %d\nENEMIES: %d",
			m_msgIn.posQX,m_msgIn.posQY,
			m_msgIn.stars, m_msgIn.stations, m_msgIn.enemies);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		swprintf_s(textbuff, _countof(textbuff), 
			L"\n\n\n\n\nREMAINING TURNS: %d / 35\n\nREMAINING ENEMIES: %d",
			m_msgIn.turns, m_msgIn.enemies);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		swprintf_s(textbuff, _countof(textbuff), 
			L"\n\n\n\n\n\n\n\n\nSHIPSTATUS\nENERGY: %d",
			m_msgIn.energy);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		Systemstext();

		swprintf_s(textbuff, _countof(textbuff), 
			L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSHIELDS: %d",
			m_msgIn.shields);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));
	}
	else
	{
		//prints location info
		swprintf_s(textbuff, _countof(textbuff), 
			L"QUADRANT: %d, %d\nSECTOR: %d,%d\nCONDITION: %s\n\n\nREMAINING TURNS: %d / 35",
			m_msgIn.posQX,m_msgIn.posQY,
			m_msgIn.posX,m_msgIn.posY,
			L"Green",m_msgIn.turns);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		//shipstatus and systems information
		swprintf_s(textbuff, _countof(textbuff), 
			L"\n\n\n\n\n\n\nSHIPSTATUS\nENERGY: %d",
			m_msgIn.energy);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));

		Systemstext();

		swprintf_s(textbuff, _countof(textbuff), 
			L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSHIELDS: %d\n\nMISSILES: %d / 10\n\nBLASTERS:",
			m_msgIn.shields, m_msgIn.missiles);

		m_pFont->DrawText(0, textbuff,
			-1, &rect, 
			DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 0));
	}
}
void Menu::Systemstext(void)
{
	GetWindowRect(hWnd, &rect);
	rect.right = 1100;
	rect.bottom = 600;
	rect.left = 600;
	rect.top = 0;
	m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\nACTIVE SYSTEMS",	
		-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
		D3DCOLOR_ARGB(255, 0, 255, 0));

	if(m_msgIn.hyperdrive)
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\nHYPERDRIVE",	
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 150));
	}
	else
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\nHYPERDRIVE",	
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(50, 0, 255, 150));
	}
	if(m_msgIn.sublight)
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\nSUB-LIGHT",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 150));
	}
	else
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\nSUB-LIGHT",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(50, 0, 255, 150));
	}
	if(m_msgIn.scanner)
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLR-SCAN",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 150));
	}
	else
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLR-SCAN",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(50, 0, 255, 150));
	}
	if(m_msgIn.missile)
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMISSILES",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 150));
	}
	else
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMISSILES",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(50, 0, 255, 150));
	}
	if(m_msgIn.blaster)
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nBLASTERS",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 150));
	}
	else
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nBLASTERS",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(50, 0, 255, 150));
	}
	if(m_msgIn.shield)
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSHIELDS",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(255, 0, 255, 150));
	}
	else
	{
		m_pFont->DrawText(0, L"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSHIELDS",
			-1, &rect, 	DT_TOP | DT_LEFT | DT_NOCLIP, 
			D3DCOLOR_ARGB(50, 0, 255, 150));
	}
}

void Menu::ShowHelp(void)
{	
	DrawBackButton();
	m_pFont->DrawText(0, L"HELP", -1, &rect, 
		DT_TOP | DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 0, 0));
	//instructions and controls
	m_subFont->DrawText(0, L"Instructions\nAttack = A\nStop = S\nSelect Regiment = LMB\nAttack/Move Regiment = RMB\nRotate Camera = Hold RMB\nMove Camera = Arrow keys or MMB", -1, &rect, 
		DT_VCENTER | DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 80, 0));
}
//void Menu::ShowOptions(void)
//{	
//	DrawBackButton();
//	DrawOptionsButtons();
//	m_pFont->DrawText(0, L"OPTIONS", -1, &rect, 
//		DT_TOP | DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 0, 0));
//	
//	char VolumeLevel[64];										
//	sprintf_s(VolumeLevel, 64, "\nMusic:  %.0f\n\n\nSound:  %.0f",(m_MusicVolume*10),(m_SoundVolume*10));
//
//	m_subFont->DrawText(0, VolumeLevel, -1, &rect, 
//		DT_VCENTER | DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 0, 0, 0));
//}
void Menu::ShowCredits(void)
{	
	DrawBackButton();
	m_pFont->DrawText(0, L"CREDITS", -1, &rect, 
		DT_TOP | DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 0, 0));
	m_subFont->DrawText(0, L"GSP362 Project\nOf Gods and Fortune\n\nChris Dickinson\nDavid Fairweather\nGee Yi Wong", -1, &rect, 
		DT_VCENTER | DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 80, 0));
}
void Menu::DrawBackButton(void)
{
	//m_pSprite->Begin(D3DXSPRITE_ALPHABLEND |D3DXSPRITE_SORT_DEPTH_FRONTTOBACK );//|D3DXSPRITE_OBJECTSPACE);    // begin sprite drawing with transparency

	//Vec_MainButtons::iterator i = vMbutton.begin(); 
	//if(i[BUTTON_BACK]->GetID() == BUTTON_BACK)
	//{
	//	i[BUTTON_BACK]->Render(false);
	//}
	//m_pSprite->End();
}
void Menu::ClickBack(void)
{
	//Vec_MainButtons::iterator i = vMbutton.begin(); 
	//if(i[BUTTON_BACK]->isMouseOver() && i[BUTTON_BACK]->GetID() == BUTTON_BACK)
	//{
	//	if(m_mouseDown)
	//	{
	//		i[BUTTON_BACK]->Pressed();
	//		if(!gDInput->mouseButtonDown(0))
	//		{
	//			ChangeMenuStates(MAIN_MENU);
	//			m_mouseDown = false; i[BUTTON_BACK]->Unpressed();
	//			//SOUNDMANAGER->MusicStop() ;
	//		}
	//	}
	//	else 
	//	{
	//		if(m_mouseDown)
	//		{m_mouseDown = false;	i[BUTTON_BACK]->Unpressed();}
	//	}
	//}else { i[BUTTON_BACK]->Unpressed();}
}
//void Menu::ClickFullScreen(void)
//{
//	Vec_OptsButtons::iterator i = vObutton.begin(); 
//
//	if(i[BUTTON_FULLSCREEN]->isMouseOver() && i[BUTTON_FULLSCREEN]->GetID() == BUTTON_FULLSCREEN)
//	{
//		if(m_mouseDown)
//		{
//			if(m_windowed)
//			{
//				gD3DApplication->EnableFullScreenMode(true);
//				i[BUTTON_FULLSCREEN]->Pressed();
//				m_windowed = !m_windowed;
//			}
//			else
//			{
//				gD3DApplication->EnableFullScreenMode(false);
//				i[BUTTON_FULLSCREEN]->Unpressed(); m_windowed = true;
//			}
//			m_mouseDown = false;
//		}
//	}
//}
void Menu::OnLostDevice(void)
{
	m_pFont->OnLostDevice();
	m_subFont->OnLostDevice();
	m_pSprite->OnLostDevice();
}
void Menu::OnResetDevice(void)
{
	m_pFont->OnResetDevice();
	m_subFont->OnResetDevice();
	m_pSprite->OnResetDevice();
}
void Menu::MenuClear(void)
{
	Vec_Quadrants::iterator i = vQuads.begin();
	while (vQuads.size() > 0)	//while thers stuff in the vector
	{
		delete *i;	//delete
		i = vQuads.erase(i);
	}
	Vec_Sectors::iterator o = vSects.begin();
	while (vSects.size() > 0)	//while thers stuff in the vector
	{
		delete *o;	//delete
		o = vSects.erase(o);
	}

	Vec_GButtons::iterator b = vGButtons.begin();
	while (vGButtons.size() > 0)	//while thers stuff in the vector
	{
		delete *b;	//delete
		b = vGButtons.erase(b);
	}

	Vec_QButtons::iterator q = vQButtons.begin();
	while (vQButtons.size() > 0)	//while thers stuff in the vector
	{
		delete *q;	//delete
		q = vQButtons.erase(q);
	}
}

// Resets menu parameters in case we return to the menu later
void Menu::Reset(void)
{
	m_pressedPlay = false;
}